<template>
  <view class="container">
    <view class="sign-in-header-box">
      <view class="sign-in-title">签到</view>
      <!-- <view class="sign-in-day">
				<text>已坚持</text>
				<view class="day">16</view>
				<text>天签到</text>
			</view> -->
      <view class="sign-in-text">打卡签到赢好礼</view>
      <view class="sign-in-box-bg"> 连续签到7天 即可瓜分大礼 </view>
    </view>
    <view style="padding: 20rpx 40rpx">
      <view class="content-box">
        <view style="text-align: center; padding: 30rpx 0">已经签到7天了</view>
        <view style="padding-bottom: 80rpx">
          <u-steps :current="current" activeColor="#ffaa00">
            <u-steps-item desc="周一"></u-steps-item>
            <u-steps-item desc="周二"></u-steps-item>
            <u-steps-item desc="周三"></u-steps-item>
            <u-steps-item desc="周四"></u-steps-item>
            <u-steps-item desc="周五"></u-steps-item>
            <u-steps-item desc="周六"></u-steps-item>
            <u-steps-item desc="周天"></u-steps-item>
          </u-steps>
        </view>
        <view>
          <view
            ><u-button
              type="primary"
              text="签到"
              color="#ffaa00"
              @click="signInClick"
            ></u-button
          ></view>
        </view>
      </view>
    </view>
  </view>
</template>

<script>
import { checkIn } from "@/api/axios/Space.js";
import store from "@/store/index.js";
export default {
  components: {},
  data() {
    return {
      openId: "openId",
      current: 0,
    };
  },
  methods: {
    signInClick() {
      let _this = this;
      let mapData = store.state.mapData;
      if (mapData.address) {
        checkIn({
          openId: this.openId,
          location: mapData.address,
          longitude: mapData.location.lng,
          latitude: mapData.location.lat,
        }).then((res) => {
          _this.clue({
            action: "12",
            eventType: "1",
          });
          uni.navigateBack({
            delta: 1,
          });
        });
      } else {
        checkIn({
          openId: this.openId,
          // location: mapData.address,
          // longitude: mapData.location.lng,
          // latitude: mapData.location.lat,
        }).then((res) => {
          uni.showToast({
            icon: "none",
            title: res.message,
            duration: 2000,
            success() {
              uni.navigateBack({
                delta: 1,
              });
            },
          });
        });
      }
    },
  },
  onLoad() {
    let openId = uni.getStorageSync("openId");
    this.openId = openId;
  },
};
</script>

<style lang="scss" scoped>
@import "./index.scss";
</style>